#!/bin/bash

# file        {{ var_filename }}.sh
# brief       XXXX
# note        XXXX
# author      {{ var_author }}({{ var_email }})
# date        {{ var_date }}
# version     1.0

SCRIPT_DIR=$(dirname "$(readlink -f "$0")")

# 函数：检查上一个脚本的退出状态
# 参数：
#   prompt：提示信息    
# 示例: _CHECK_ERRORLEVEL $? "Test" "True"
_CHECK_ERRORLEVEL() {
    local errorlevel=$1
	local prompt="${2:-}"
    local force_exit="${3:-true}"  # 默认为 true
    
    # 将 force_exit 转换为小写，以便大小写不敏感的比较
    force_exit=$(echo "$force_exit" | tr '[:upper:]' '[:lower:]')

    if [ $errorlevel -eq 0 ]; then  # 判断上一个脚本的退出状态
        echo "   ${prompt} succeeded ✌ "
    else
error_art="
 _____ ____  ____   ___  ____       
| ____|  _ \|  _ \ / _ \|  _ \      
|  _| | |_) | |_) | | | | |_) |     
| |___|  _ <|  _ <| |_| |  _ <      
|_____|_| \_\_| \_\\\\___/|_| \_\     
"
        echo "${error_art}"
        echo "   ${prompt} failed with errorlevel $errorlevel ☠ "
        if [ "$force_exit" = "true" ]; then
            exit 1
        fi
    fi
    return $errorlevel
}



echo ============BIGEN: {{ var_filename }}.sh============








echo ============END: {{ var_filename }}.sh============
_CHECK_ERRORLEVEL $? {{ var_filename }} True
